﻿#include "cameradal.h"
#include<QSqlQuery>
#include<QSqlDatabase>
cameraDal::cameraDal()
{

}
bool cameraDal::add(QString cameraname,QString cameranum){
    char SerialNumber[32]={0};
    QString sq=QString("INSERT INTO update camera_device set 相机序列号="+cameranum+" where 设备名称="+cameraname).arg(SerialNumber).arg(0);
    QSqlDatabase  db;
    QSqlQuery query(db);  //指定连接的数据库
    bool r= query.exec(sq);//执行SQl语句
    return r;
}
bool cameraDal::remove(QString cameraname,QString cameranum){
    char SerialNumber[32]={0};
    QString sq=QString("Delete From update camera_device set 相机序列号="+cameranum+" where 设备名称="+cameraname).arg(SerialNumber).arg(0);
    QSqlDatabase  db;
    QSqlQuery query(db);  //指定连接的数据库
    query.exec(sq);//执行SQl语句
    bool r= query.exec(sq);//执行SQl语句
    return r;
}
bool cameraDal::modify(QString cameraname,QString cameranum){
    char SerialNumber[32]={0};
    QString sq=QString("UPDATE update camera_device set 相机序列号="+cameranum+" where 设备名称="+cameraname).arg(SerialNumber).arg(0);
    QSqlDatabase  db;
    QSqlQuery query(db);  //指定连接的数据库
    query.exec(sq);//执行SQl语句
    bool r= query.exec(sq);//执行SQl语句
    return r;
}
void cameraDal::search(QString cameraname,QString cameranum){
    char SerialNumber[32]={0};
    QString sq=QString("Search update camera_device set 相机序列号="+cameranum+" where 设备名称="+cameraname).arg(SerialNumber).arg(0);
    QSqlDatabase  db;
    QSqlQuery query(db);  //指定连接的数据库
    query.exec(sq);//执行SQl语句
}
